package hu.issue.web;

import hu.issue.ejb.TaskService;
import hu.issue.framework.web.Constants;
import hu.issue.framework.web.controller.Controller;
import hu.issue.framework.web.controller.Inject;
import hu.issue.framework.web.controller.RequiredRole;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

@RequiredRole(Constants.ROLE_USER)
public class AssignTaskToMySelfController implements Controller {
	@Inject
	private TaskService taskService;

	@Override
	public String handleRequest(final HttpServletRequest request, final HttpServletResponse response) throws Exception {
		final int taskId = Integer.parseInt(request.getParameter("taskId"));
		final int projectId = Integer.parseInt(request.getParameter("projectId"));
		this.taskService.assignTaskToMySelf(taskId);
		return "redirect:project.do?projectId=" + projectId;
	}

}
